home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
os2
/
ppdial29.zip
/
pppdial.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-07-13
|
32KB
|
936 lines
/* REXX */
/*
OS/2 WARP REXX script to redial a PPP provider when busy.
Written by: Don Russell (c) 1995, 1996
send email to don_russell@ibm.net
Many changes introduced by Ed Tomlinson in version 2.4
send email to tomlins@CAM.ORG
Change log: (most recent first)
13 July 1996 Version: 2.9
Improve error checking when examining ini files.
(other history removed, see documentation if interested)
8 April 1995: Original
stop
A note about distribution.... This script may be distributed freely provided
I am given credit for it. Please do not alter my name or email address
nor the manner in which they are displayed.
If you have comments regarding this script, plese let me know by email. I'll
support it as time, and my ability permit. ;-)
NOTE: I've tested this as well as I can with a single provider. Given the many
providers and configurations, this may not work properly the first time.
If you have problems with pppdial, please refer to the pppdial.htm file.
Specific things to watch for are the EXACT prompts used when the host
system is asking for a userid and password. The prompts that pppdial expect
are "ogin:" (no quotes) and "ssword:" (no quotes) for userid and password
respectfully.
If your system uses someting different, you will need to use the response file
option. (Or modify the script slightly. This is not recommended because you will
have to make the same changes in the next version etc. too.)
-----------------------------------------------------------------*/
VersionTag = 'PPPDIAL V2.9'
RFile = ''
UsePhoneNumberFile = 0
signal on halt
LoginPrompt = 'ogin:'
PasswordPrompt = 'ssword:'
LoginId = 'userid'
Password = 'password'
call rxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
parse upper source . . MyDrivePathName
etcDrivePath = translate( value( 'etc',,'OS2ENVIRONMENT') )
iniFile = etcDrivePath || '\TCPOS2.INI'
/* before we get too carried away, let's see what we're doing... */
/* if the ppp_ functions are registered, I assume we're about to */
/* start a ppp connection... */
/* If neither the ppp_ functions NOR the slip_ functions are registered */
/* then I assume we're installing ... */
PPPService = ( RxFuncQuery( 'ppp_com_input' ) = 0 )
SLIPService = ( RxFuncQuery( 'slip_com_input' ) = 0 )
if \(PPPService | SLIPService) then do
call NotFromDialer
exit 0
end /* Do */
/* Set some definitions for easier COM strings */
bs = '08'x
cr='0d'x
crlf='0d0a'x
if PPPService then
parse arg interface , port , . , RFile
else
parse arg interface , RFile /* different when slip :-( */
if RFile \= '' then do
/* The use of slippm.exe is a bit tricky... extra <CR> cause havoc :-( */
/* Check to see if there are any in the spec and warn the user. */
if pos(cr, RFile) \= 0 then do
call lineout , 'Response file is not coded correctly.'
call lineout , 'Do not press the enter key when typing the response file name'
call lineout , 'in the login sequence field in slippm.exe'
exit 8
end /* Do */
RFile = stream( RFile, 'C', 'QUERY EXISTS' )
if RFile = '' then do
if substr(Rfile, 2, 1) \= ':' then do
call lineout , 'Response file must have drive and path information'
call lineout , 'or the working directory path of the dialer must be set.'
exit 8
end /* Do */
else do
call lineout , 'Response file not found.'
call lineout , 'Processing ended.'
exit 8
end
end /* Do */
end /* Do */
/*--------------------------------------------------------------------------*/
/* Initialization and Main Script Code */
/*--------------------------------------------------------------------------*/
remain_buffer = ''
UsePhoneNumberFile = 0
UsePhoneNumberList = 0
Disable = 0
ActualCarrier = 0 /* to be determined .... */
UpperCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
LowerCase = 'abcdefghijklmnopqrstuvwxyz'
/* initialize variables that MAY be set by a response file... */
BeepWanted = 1 /* beep when successful connection */
DialPrefix = ''
HostTimeout = 60
init1 = ''
init2 = ''
MaxAttempts = 32767
MinCarrier = 0
ModemEscapeSequence = '+++'
ModemRegS7 = -1 /* if still < 0 later, we get it from the modem */
ModemResetCommand = 'ATH0Z'
pause = 5 /* seconds between dial attempts */
PhoneNumber = 'xxx-xxxx' /* may be a blank delimited list, or file name */
prefix = 'ATDT' /* add any other commands required */
UseDialer = 1 /* yes, we're using the IBM "Dial Other..." */
AutoStart = ''
if UseDialer then do
/* Get userid/password etc. from the dialer */
ConnectTo = strip( SysIni( iniFile, 'CONNECTION', 'CURRENT_CONNECTION' ), 'T', '00'x )
if (ConnectTo = '') | (ConnectTo = 'ERROR:') then do
ConnectTo = strip( SysIni( iniFile, 'CONNECTION', 'LAST_CONNECTION' ), 'T', '00'x )
end /* Do */
x = Strip( SysIni( iniFile, ConnectTo, 'INIT' ), 'T', '00'x )
if x <> 'ERROR:' then init1 = x
x = Strip( SysIni( iniFile, ConnectTo, 'INIT2' ), 'T', '00'x )
if x <> 'ERROR:' then init2 = x
x = Strip( SysIni( iniFile, ConnectTo, 'AUTOSTART'), 'T', '00'x );
if x <> 'ERROR:' then AutoStart = x
x = Strip( SysIni( iniFile, ConnectTo, 'PREFIX' ), 'T', '00'x )
if x <> 'ERROR:' then Prefix = x
x = Strip( SysIni( iniFile, ConnectTo, 'DIAL_PREFIX' ), 'T', '00'x )
if x <> 'ERROR:' then DialPrefix = x
x = Strip( SysIni( iniFile, ConnectTo, 'PHONE_NUMBER' ), 'T', '00'x )
if x <> 'ERROR:' then PhoneNumber = x
x = Strip( SysIni( iniFile, ConnectTo, 'LOGIN_ID' ), 'T', '00'x )
if x <> 'ERROR:' then LoginId = x
x = Strip( SysIni( iniFile, ConnectTo, 'PWD' ), 'T', '00'x )
if x <> 'ERROR:' then Password = x
x = Strip( SysIni( iniFile, ConnectTo, 'DISABLE' ), 'T', '00'x )
if x <> 'ERROR:' then Disable = ( x = 'TRUE' )
x = Strip( SysIni( iniFile, ConnectTo, 'DISABLE_SEQUENCE' ), 'T', '00'x )
if x <> 'ERROR:' then DisableSequence = x
if (PPPService & SLIPService) then do
x = Strip( SysIni( iniFile, ConnectTo, 'SERVICE' ), 'T', '00'x )
if x <> 'ERROR:' then PPPService = ( x = 'PPP' )
end
drop x
end /* Do */
if RFile \= '' then do
if \ProcessRFileCommands() then do
say 'Processing ended due to response file error.'
exit 8
end /* Do */
if (( RFile.1 \= 'GO') & (RFile.1 \= 'WAIT' )) then do
call lineout , 'First line of response file must be GO or WAIT.'
call lineout , 'Processing ended.'
exit 8
end /* Do */
end
else do
RFile.0 = 0
end /* Do */
if \datatype( pause, 'W' ) then do
call lineout , 'invalid time delay specified - 5 sec assumed'
pause = 5
end /* Do */
pause = max( 2, pause ) /* A minimum delay of 2 seconds is required to guarantee dial tone */
/* The "phone number" may be a list of numbers, or a file spec of a list of numbers. */
if words( PhoneNumber ) > 1 then do
/* Yup, it's a list itself... build a stem of numbers to use */
/* However, it could be a list of "number/pause" pairs... */
x = 0
do i = 1 to words( PhoneNumber )
x = x + 1
PhoneNo.i = word( PhoneNumber, x )
if right( PhoneNo.i, 1 ) = ';' then do
if x >= words( PhoneNumber) then do
call lineout , 'Do not include semicolon on last number dialed'
exit 8
end /* Do */
PhoneNo.i = PhoneNo.i word( PhoneNumber, x + 1 )
x = x + 1
end /* Do */
end /* do */
PhoneNo.0 = i - 1
UsePhoneNumberList = 1
end /* Do */
else do
PhoneNumberFile = stream( PhoneNumber, 'C', 'QUERY EXISTS' )
if PhoneNumberFile \= '' then do
/* The phone numbers are in a file. Build a stem variable and close the file */
UsePhoneNumberFile = 1
do i = 1 by 1 while lines( PhoneNumberFile )
PhoneNo.i = linein( PhoneNum